<template>
  <div v-if="Object.keys(shop).length !== 0" class="box">
    <div class="portrait">
      <img :src="shop.logo" alt="" />
      <span>{{ shop.name }}</span>
    </div>
    <div class="center">
      <div class="sell">
        <p>{{ shop.sells | sellCountFilter }}</p>
        <p>总销量</p>
      </div>
      <div class="goods-count">
        <p>{{ shop.goodsCount }}</p>
        <p>全部宝贝</p>
      </div>
      <div class="border"></div>
      <div class="score">
        <p v-for="(item, index) in shop.score">
          {{ item.name }}
          <span :class="{ active: item.isBetter }">
            {{ item.score }}
            <div class="bor" :class="{ active2: item.isBetter }">
              {{ item.isBetter ? "高" : "底" }}
            </div>
          </span>
        </p>
      </div>
    </div>
    <a href="javascript:;" class="bottom">进店逛逛</a>
  </div>
</template>

<script>
export default {
  props: {
    shop: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  filters: {
    sellCountFilter: function (value) {
      if (value < 10000) return value;
      return (value / 10000).toFixed(1) + "万";
    },
  },
};
</script>

<style scoped>
.box {
  padding: 8px 8px 20px;
  border-bottom: 3px solid #e7e5e7;
}

.portrait {
  margin-top: 20px;
}

.portrait img {
  width: 50px;
  border-radius: 50%;
  border: 2px solid #e7e5e7;
  vertical-align: middle;
}

.portrait span {
  margin-left: 10px;
  font-size: 16px;
  font-weight: 700;
}

.center {
  display: flex;
  justify-content: space-evenly;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  padding-top: 20px;
}

.sell {
  align-self: center;
}

.goods-count {
  align-self: center;
}

.border {
  width: 2px;
  background-color: #e7e5e7;
}

.score {
  align-self: center;
  text-align: left;
}

.score > p {
  position: relative;
  font-size: 12px;
}

.score span {
  color: green;
}

.score span.active {
  color: red;
}

.score div {
  position: absolute;
  right: -20px;
  top: 2px;
  display: inline-block;
  background-color: green;
  width: 15px;
  height: 15px;
  text-align: center;
  line-height: 15px;
  color: #fff;
  font-weight: 500;
}

.score div.active2 {
  background-color: red;
}

p {
  margin: 5px 0;
}

.bottom {
  display: block;
  margin: 20px auto 0;
  width: 33%;
  height: 25px;
  background-color: #f1f1eece;
  line-height: 25px;
  text-align: center;
  border-radius: 15px;
}
</style>